import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {

        List<Integer> arrayList = new ArrayList<>();//一般采用左边接口右边类的写法
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        List<Integer> linkedList = new LinkedList<>(arrayList);
        //使用迭代器正向遍历链表
        ListIterator<Integer> lit =  linkedList.listIterator();
        while(lit.hasNext()) {
            System.out.print(lit.next() + " ");
        }
        System.out.println();
        //使用迭代器反向遍历
        ListIterator<Integer> lit2 =  linkedList.listIterator(linkedList.size());
        while(lit2.hasPrevious()) {
            System.out.print(lit2.previous() + " ");
        }
        System.out.println();


    }
    public static void main1(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addFirst(10);
        myLinkedList.addFirst(20);
        myLinkedList.addFirst(30);
        myLinkedList.addFirst(40);
        myLinkedList.remove(10);

        myLinkedList.display();


    }
}
